<template>
  <div class="page-title">
    <div class="left">
      <img style="width: 20px;height: 20px" :src="project ? icon2 : icon" alt=""/>
      <span class="span">{{ name }}</span>
    </div>
    <div class="right">
      <div v-for="item in tags" :key="item.name" class="item" :class="[tabActive === item.name && 'item-active']"
           @click="changeTag(item.name)">
        <img style="width: 16px" :src="tabActive === item.name ? item.imgS : item.img" alt="img"/>
        <span>{{ item.name }}</span>
      </div>
    </div>
  </div>
</template>
<script>
  import icon from '@img/project/icon-khzb.png';
  import img1 from '@img/project/icon-xmzl.png';
  import imgs1 from '@img/project/icon-xmzl-select.png';
  import img2 from '@img/project/icon-slzb.png';
  import imgs2 from '@img/project/icon-slzb-select.png';
  import icon2 from '@img/project/icon-xmfx.png'

  export default {
    name: 'ProjectTitle',
    props: ['name','project'],
    data () {
      return {
        icon: icon,
        icon2:icon2,
        tags: [
          {
            name: '投资额占比',
            img: img1,
            imgS: imgs1
          },
          {
            name: '数量占比',
            img: img2,
            imgS: imgs2
          }
        ],
        tabActive: '投资额占比'
      };
    },
    methods: {
      changeTag (name) {
        this.tabActive = name;
        this.$emit('changeTabName',name)
      }
    }
  };
</script>

<style scoped lang="less">
  .page-title {
    display: flex;
    height: 50px;
    align-items: center;
    font-size: inherit;
    justify-content: space-between;

    .left {
      display: flex;
      align-items: center;
    }

    .span {
      padding-left: 10px;
    }

    .right {
      width: 250px;
      height: 36px;
      background: #EFEFF0;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0 4px;
      box-sizing: border-box;
    }

    .item {
      text-align: center;
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;

      img {
        margin-right: 2px;
      }
    }

    .item:hover {
      cursor: pointer;
    }

    .item-active {
      height: 28px;
      background: #FFFFFF;
      border-radius: 8px;
      color: #0063F7;
    }
  }
</style>
